<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.DriverManager" %><%--
  Created by IntelliJ IDEA.
  User: 44659
  Date: 2018/5/20
  Time: 21:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>删除用户</title>
</head>
<body>

<%

    //3+1

    String id  =request.getParameter("id");
    Connection connection=null;
    PreparedStatement statement=null;

    String sql="DELETE from t_users where id=?";

    Class.forName("com.mysql.jdbc.Driver");

    connection= DriverManager.getConnection(
            "jdbc:mysql://localhost:3306/sctu_javaweb_2018?serverTimezone=UTC",
            "root",
            "123456"
    );
    statement=connection.prepareStatement(sql);

    statement.setString(1, id);
    int result=statement.executeUpdate();
    String msg="删除失败！";
    if (result==1){
        msg="删除成功！";
    }

    statement.close();
    connection.close();

%>

<script>window.alert('<%=msg%>');</script>

<%
    response.setHeader("Refresh","1;url=userList");
%>


</body>
</html>
